<template>
	<view>
		<u-mask :show="show" :duration="400" :zoom="true" :custom-style="{background: '#ffffff'}"></u-mask>
		<view class="u-page">
			<!-- 所有内容的容器 -->
			<view v-if="show == false">
				<error></error>
			</view>
			<view v-if="show ==true && current == 0">
				<index></index>
			</view>
			<view v-if="current == 1">
				<menus></menus>
			</view>
			<view v-if="current == 3">
				<order></order>
			</view>
			<view v-if="current == 4">
				<user></user>
			</view>
		</view>
		<view v-show="show">
			<!-- 与包裹页面所有内容的元素u-page同级，且在它的下方 -->
			<u-tabbar v-model="current" :list="list" :mid-button="true" :before-switch="beforeSwitch"></u-tabbar>
		</view>
	</view>
</template>

<script>
	import index from '../../pages/tabbar/index.vue'
	import menus from '../../pages/menu/index.vue'
	import order from '../../pages/order/index.vue'
	import user from '../../pages/center/index.vue'
	import error from '../../pages/error/index.vue'
	export default {
		components:{
			index,
			menus,
			order,
			user,
			error
		},
		data() {
			return {
				list: [{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						count: 2,
						isDot: true,
						customIcon: false,
					},
					{
						iconPath: "photo",
						selectedIconPath: "photo-fill",
						text: '点餐',
						customIcon: false,
					},
					{
						iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
						selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
						text: '购物车',
						midButton: true,
						customIcon: false,
					},
					{
						iconPath: "play-right",
						selectedIconPath: "play-right-fill",
						text: '订单',
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
						count: 23,
						isDot: false,
						customIcon: false,
					},
				],
				current: 0,
				show:false ,//是否显示底部导航
			}
		},
		onLoad() {
			this.getStatus();
		},
		methods:{
			beforeSwitch(index) {
				this.current = index
				console.log(this.current)
			},
			//获取状态动态显示页面
			getStatus(){
				// 带上header(对象形式)，由于header为第三个参数，如果不需要请求参数，第二个参数传一个空对象"{ }"即可
				this.$u.get('https://api.virapi.com/vir_github23b3hh1af2827/sehochen/status', {}, {
					'app-token': '$2a$10$8bKLatJDWuGB0UQGnppBkeO9tkFgPc7BuL2UgQ6RX4eJIlxyo6qJS'
				}).then(res => {
					console.log(res.data.status);
					if(res.data.status == 0){
						this.show = false
					}else{
						this.show = true
					}
					
				});
			}
		}
	}
</script>
<style scoped>

</style>
